const urlKYXContent = 'ECI/BasicEnglish/BasicEnglishBase.ashx?AppKey=049BD15C6FC04BD80808A601DC46E50515CBEEA33FB29AB4';
const urlKYXContents = 'ECI/WeChatSmallProgram/WeChat_Base.ashx?AppKey=049BD15C6FC04BD80808A601DC46E50515CBEEA33FB29AB4';
var wxRequest = (params, url) => {
  wx.request({
    url,
    method: params.method || 'GET',
    data: params.dataDic || {},
    header: {
      Accept: 'application/json',
      'content-type': params.contentType || 'application/json',
    },
    success: (res) => {
      if (params.success) {
        params.success(res);
      }
    },
    fail: (res) => {
      if (params.fail) {
        params.fail(res);
      }
    },
    complete: (res) => {
      console.log('本次网络请求的url:', url)
      console.log('本次网络请求发送的数据:', params.dataDic)
      if (params.complete) {
        params.complete(res);
      }
    },
  });
};
//首页单元列表
var methodBasicEnglish_UnlockInformation = (params) => {
  wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_UnlockInformation`);
};
//看图识单词接口
var methodBasicEnglish_Img = (params) => {
  wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_Img`);
};
//看图识单词测验接口
var methodBasicEnglish_WordDetection = (params) => {
  wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_WordDetection`);
};

// 获取微信openid
var methodRequestWechatAPI = (params) => {
  wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContents}&action=RequestWechatAPI`);
};
//获取任务的数据
var methodBasicEnglish_GetTaskData = (params) => {
    wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_GetTaskData`);
}
//获取任务状态
var methodBasicEnglish_GetTask = (params) => {
    wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_GetTask`);
}
//获取游戏状态
var methodBasicEnglish_GetGameStatus = (params) => {
    wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_GetGameStatus`);
}
//解锁关卡（通用）
var methodBasicEnglish_Unlock = (params) => {
    wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_Unlock`);
}
//判断是否解锁
var methodBasicEnglish_ModuleSubtitleIsUnlock  = (params) => {
    wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_ModuleSubtitleIsUnlock`);
}
//获取下一个模块ID
var methodBasicEnglish_NextModuleId = (params) => {
    wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_NextModuleId`);
}
//获取游戏数据
var methodBasicEnglish_GetGameData = (params) => {
    wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_GetGameData`);
};
//游戏失败结束任务（游戏）人数统计
var methodBasicBasicEnglish_CountStatistics = (params) => {
    wxRequest(params, `${getApp().globalData.apiUrl}/${urlKYXContent}&action=BasicEnglish_CountStatistics`);
};


module.exports = {
    //获取下一个模块ID
    methodBasicEnglish_NextModuleId,
    //判断是否解锁
    methodBasicEnglish_ModuleSubtitleIsUnlock,
    //获取任务的数据
    methodBasicEnglish_GetTaskData,
    //获取微信OpenId
    methodRequestWechatAPI,
    //获取任务状态
    methodBasicEnglish_GetTask,
    //获取游戏状态
    methodBasicEnglish_GetGameStatus,
    //解锁关卡（通用）
    methodBasicEnglish_Unlock,
    //获取首页信息
    methodBasicEnglish_UnlockInformation,
    //看图识单词接口
    methodBasicEnglish_Img,
    //看图识单词测验接口
    methodBasicEnglish_WordDetection,
    //获取游戏数据
    methodBasicEnglish_GetGameData,
    //游戏失败结束任务（游戏）人数统计
    methodBasicBasicEnglish_CountStatistics,
}

